package me.acomma.groot.application.user;

import me.acomma.groot.domain.user.User;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.Mappings;

import java.util.List;

@Mapper(componentModel = "spring")
public interface UserAssembler {
    @Mappings({
            @Mapping(target = "userId", source = "userId.id"),
    })
    UserData toUserData(User user);

    @Mappings({
            @Mapping(target = "userId", source = "userId.id"),
    })
    List<UserData> toUserDataList(List<User> users);

    @Mappings({
            @Mapping(target = "userId", ignore = true),
            @Mapping(target = "createTime", ignore = true),
            @Mapping(target = "id", ignore = true),
            @Mapping(target = "updateTime", ignore = true)
    })
    User toUser(PageQueryUserCommand command);
}
